package main

import (
	"go.uber.org/zap"
)

// zap的测试
func main() {
	logger, _ := zap.NewProduction() //这个适用于生产环境
	defer logger.Sync()              // flushes buffer, if any
	url := "https://imooc.com"

	//----logger方式
	logger.Info("failed to fetch URL",
		zap.String("url", url),
		zap.Int("nums", 3),
	)

	//----sugar方式 性能差些
	//sugar := logger.Sugar()
	//sugar.Infow("failed to fetch URL",
	//	// Structured context as loosely typed key-value pairs.
	//	"url", url,
	//	"attempt", 3,
	//)
	//sugar.Infof("Failed to fetch URL: %s", url)
}
